<?php
defined('IN_ADMIN') or exit('No permission resources.');
include $this->admin_tpl('header','admin');
?>
<link type="text/css" rel="stylesheet" href="<?php echo CSS_PATH; ?>product/edit_hongbao.css" />
<script type="text/javascript">
<!--
function showunit(num) {
	switch(num) {
		case 0:
			document.getElementById('l').style.display = 'none';
		break;
		case 1:
			document.getElementById('l').style.display = 'none';
		break;
		case 2:
			document.getElementById('l').style.display = 'block';
		break;
	}
}

function showNotice(obj) {
	if(document.getElementById(obj).style.display == 'block') {
		document.getElementById(obj).style.display = 'none';
	}else{
		document.getElementById(obj).style.display = 'block';
	}
}
function edit() {
	if($('#typeName').val() == ''){
		alert('类型名称不能为空！');
		$('#typeName').focus();
		return false;
	}
	if($('#type_money').val() == ''){
		alert('红包金额不能为空！');
		$('#type_money').focus();
		return false;
	}
	if($('#min_goods_amount').val() == ''){
		$('#min_goods_amount').val(0);
	}
	if($('#min_amount').val() == ''){
		$('#min_amount').val(0);
	}
}
//-->
</script>
<style>
table td {border-bottom:1px solid #EEE; padding:4px 0 4px 8px;}
table td.label {padding:4px 0 4px 8px;}
</style>
<div class="main-div">
    <form name="editForm" method="post" action="" id="myform" onsubmit="return edit()">
    <table width="100%">
        <tbody>
            <tr>
                <td class="label">类型名称 :</td>
                <td>
                    <input type="text" size="20" maxlength="30" name="search[type_name]" id="typeName">     
                </td>
            </tr>
            <tr>
                <td class="label"><a title="点击此处查看提示信息" href="javascript:showNotice('Type_money_a');"><img width="16" height="16" border="0" src="<?php echo IMG_PATH ?>notice.gif"></a>红包金额 :</td>
                <td>
                    <input type="text" size="20" name="search[type_money]" id="type_money">
                    <br><span id="Type_money_a" style="display:block" class="notice-span">此类型的红包可以抵销的金额</span>    
                </td>
            </tr>
            <tr>
                <td class="label"><a title="点击此处查看提示信息" href="javascript:showNotice('NoticeMinGoodsAmount');"><img width="16" height="16" border="0" src="<?php echo IMG_PATH ?>notice.gif"></a>最小订单金额 :</td>
                <td>
                    <input type="text" size="20" value="" id="min_goods_amount" name="search[min_goods_amount]">
                    <br><span id="NoticeMinGoodsAmount" style="display:block" class="notice-span">只有商品总金额达到这个数的订单才能使用这种红包</span> 
                </td>
            </tr>
            <tr>
                <td class="label">如何发放此类型红包 :</td>
                <td>
                    <input type="radio" onclick="showunit(0)" checked="true" value="0" name="search[send_type]">按用户发放      
                    <input type="radio" onclick="showunit(1)" value="1" name="search[send_type]">按商品发放      
                    <input type="radio" onclick="showunit(2)" value="2" name="search[send_type]">按订单金额发放      
                </td>
            </tr>
            <tr>
            	<td colspan="2" style="padding:0; border:0;">
                	<div id="l" style="display:none;">
                    	<table width="100%" cellpadding="0" cellspacing="0" border="0">
                        	<tr>
                                <td class="label"><a title="点击此处查看提示信息" href="javascript:showNotice('Order_money_a');"><img width="16" height="16" border="0" src="<?php echo IMG_PATH ?>notice.gif"></a>订单下限 :</td>
                                <td>
                                    <input type="text" size="20" name="search[min_amount]" id="min_amount">
                                    <br><span id="Order_money_a" style="display:block" class="notice-span">只要订单金额达到该数值，就会发放红包给用户</span>    
                                </td>
                            </tr>
                        </table>
                    </div>
                </td>
            </tr>
            <tr>
                <td class="label"><a title="点击此处查看提示信息" href="javascript:showNotice('Send_start_a');"><img width="16" height="16" border="0" src="<?php echo IMG_PATH ?>notice.gif"></a>发放起始日期 :</td>
                <td id="send_time">
					<?php echo form::date('search[send_start_date]',date('Y-m-d',time()),'')?>
                    <br><span id="Send_start_a" style="display:block" class="notice-span">只有当前时间介于起始日期和截止日期之间时，此类型的红包才可以发放</span>    
                </td>
            </tr>
            <tr>
                <td class="label">发放结束日期 :</td>
                <td id="end_time"><?php echo form::date('search[send_end_date]',date('Y-m-d',time()),'')?></td>
            </tr>
            <tr>
                <td class="label"><a title="点击此处查看提示信息" href="javascript:showNotice('Use_start_a');"><img width="16" height="16" border="0" src="<?php echo IMG_PATH ?>notice.gif"></a>使用起始日期 :</td>
                <td>
					<?php echo form::date('search[use_start_date]',date('Y-m-d',time()),'')?>
                    <br><span id="Use_start_a" style="display:block" class="notice-span">只有当前时间介于起始日期和截止日期之间时，此类型的红包才可以使用</span>    
                </td>
            </tr>
            <tr>
                <td class="label">使用结束日期 :</td>
                <td><?php echo form::date('search[use_end_date]',date('Y-m-d',time()),'')?></td>
            </tr>
            <tr>
            	<td colspan="2"><input name="dosubmit" type="submit" id="dosubmit" value="<?php echo L('submit')?>" class="dialog"></td>
            </tr>
        </tbody>
    </table>
</form>
</div>